<template>
<div class="driving_save" >
  <el-form ref="form" :model="form" label-width="80px" :row-class-name="driving_save" :rules="rules">
    <!--          v-model="carList"-->
    <el-form-item label="车牌号码" >
      <el-select v-model="form.carId" placeholder="请选择违车牌号码">
        <el-option
          v-for="item in carList"
          :key="item.id"
          :label="item.carNo"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>

    <el-form-item label="驾驶人员" >
      <el-select v-model="form.driverId" placeholder="请选择驾驶人员">
        <el-option
          v-for="item in driverList"
          :key="item.id"
          :label="item.name"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>

    <el-form-item label="违章项目" >
      <el-select v-model="form.pecOption" placeholder="请选择违章项目">
        <el-option
          v-for="item in dictionaryList"
          :key="item.id"
          :label="item.text"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>

    <el-form-item label="违章时间">
      <el-col :span="11">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.pecDate" style="width: 100%;"></el-date-picker>
      </el-col>
    </el-form-item>

    <el-form-item label="违章罚款" >
      <el-input v-model="form.fine"></el-input>
    </el-form-item>

    <el-form-item label="违章扣分">
      <el-input v-model="form.points"></el-input>
    </el-form-item>

    <el-form-item label="违章地点">
      <el-input v-model="form.pecPlace"></el-input>
    </el-form-item>

    <el-form-item label="违章备注">
      <el-input v-model="form.remarks"></el-input>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="saveViolation">立即创建</el-button>
      <el-button>取消</el-button>
    </el-form-item>


  </el-form>
</div>
</template>
<style>
.driving_save {
  width: 700px;
}
</style>

<script>
import violationApi from "@/api/violation_cjl_wzjl.js";
export default {
  data() {
    return {
      carList: {},
      driverList: {},
      dictionaryList: {},
      form: {
        carId: '',
        pecOption: '',
        pecDate: '',
        fine: '',
        points: '',
        driverId: '',
        pecPlace: '',
        remarks: ''
      },


    }
  },
  created() {
    this.findAll()

  },
  methods: {
    onSubmit() {
      console.log('submit!');

    },

    findAll() {
      violationApi.findAllCarNum().then((response) => {
        console.log("获取汽车号码牌成功");
        this.carList = response.data.carList;
        this.driverList = response.data.driverList;
        this.dictionaryList = response.data.dictionaryList;
        console.log(this.carList)
        console.log(this.driverList)
      })
    },

    saveViolation() {
      violationApi.saveViolation(this.form).then((response) => {
        this.$message({
          message: "添加成功",
          type: "success",
        });
        this.$router.push({ path: "/daily_work/violation_record" });
      })
    }
  }
}
</script>

<style>

</style>
